import { stringify } from 'qs';
import request from '@/utils/request';


/**
 * 会员列表
 * @param {*} params 
 */
export async function queryVip(params) {
  return request('/member/list', {
    method: 'POST',
    data: {
      ...params
    },
  });
}


/**
 * 查询会员详情
 * @param {*} params 
 */
export async function fetchVip(params) {
  return request(`/member/memberInfo?${stringify(params)}`);
}

/**
 * 根据当前登录人查询销售List
 * @param {*} params 
 */
export async function fetchSales(params) {
  return request('/sys/user/queryCoachAndSale', {
    method: 'POST',
    data: {
      ...params
    },
  });
}

/**
 * 根据当前登录人查询教练List
 * @param {*} params 
 */
export async function fetchCoach(params) {
  return request('/sys/user/queryCoachAndSale', {
    method: 'POST',
    data: {
      ...params
    },
  });
}


/**
 * 删除会员
 * @param {*} params 
 */
export async function removeVip(params) {
  return request(`/member/delete?${stringify(params)}`);
}

/**
 * 批量删除会员
 * @param {*} params 
 */
export async function batchRemoveVip(params) {
  return request(`/member/batchDeleteMember?${stringify(params, { arrayFormat: 'brackets' })}`);
}


/**
 * 新增会员
 * @param {*} params 
 */
export async function addVip(params) {
  return request('/member/save', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 更新会员
 * @param {*} params 
 */
export async function updateVip(params) {
  return request('/member/update', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 消费记录
 * @param {*} params 
 */
export async function fetchConsume(params) {
  return request('/member/getConsumeRecord', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 预约课程
 * @param {*} params 
 */
export async function fetchCourse(params) {
  return request(`/member/getBookingCourse?${stringify(params)}`);
}

/**
 * 体测记录
 * @param {*} params 
 */
export async function fetchBordyInfo(params) {
  return request(`/member/getMemberBodyInfo?${stringify(params)}`);
}

/**
 * 积分信息
 * @param {*} params 
 */
export async function fetchIntegral(params) {
  return request(`/member/getMemberIntegral?${stringify(params)}`);
}

/**
 * 保存体测信息
 * @param {*} params 
 */
export async function addBody(params) {
  return request('/memberBodyInfoController/save', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 会员会员卡
 * @param {*} params 
 */
export async function getMemberCard(params) {
  return request('/bookingCourse/getMemberCard', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 上传
 * @param {*} params 
 */
export async function upload(params) {
  return request('/commonInfo/uploadFile', {
    method: 'POST',
    data: params,
  });
}

/**
 * 导出
 * @param {*}    
 */
export async function exportMemberAndCard(params) {
  return request('/member/exportMemberAndCard', {
    method: 'POST',
    data: params,
  });
}

export async function queryVipBindCard(params) {
  return request('/memberCardController/queryBindCardList', {
    method: 'POST',
    data: {
      ...params
    },
  });
}